import { api } from 'boot/axios'

// Banner 和广告管理 API  type 类型（0: Banner, 1: 广告）
export interface IBPParam {
  type: number
  bannerOrder: number // 排序序号，控制显示顺序
  link: string // 链接地址
  imageUrl: string // 图片 URL
}

export interface IBPEditParam extends IBPParam {
  id: number
}

const BANNER_POSTER_URL = '/house/banner'
const BANNER_POSTER_LIST_URL = '/house/banner/list'

// banner
export function addBanner(data: IBPParam) {
  return api.post(BANNER_POSTER_URL, data)
}

export function editBanner(data: IBPEditParam) {
  return api.put(BANNER_POSTER_URL, data)
}

export function removeBanner(id: number) {
  return api.delete(`${BANNER_POSTER_URL}/${id}`)
}

export function getBannerById(id: number) {
  return api.get(`${BANNER_POSTER_URL}/${id}`)
}

export function getBannerList(type: number) {
  return api.get(BANNER_POSTER_LIST_URL, { params: { type } })
}
